# eric7.MicroPython.MicroPythonFileManagerWidget

Module implementing a file manager for MicroPython devices.

### Global Attributes

None

### Classes

MicroPythonFileManagerWidget | Class implementing a file manager for MicroPython devices.

### Functions

None

## MicroPythonFileManagerWidget

Class implementing a file manager for MicroPython devices.

### Derived from

QWidget, Ui_MicroPythonFileManagerWidget

### Class Attributes

None

### Class Methods

None

### Methods

MicroPythonFileManagerWidget | Constructor
__changeDeviceDirectory | Private slot to change the current directory of the device.
__changeLocalDirectory | Private slot to change the local directory.
__clearDeviceSelection | Private slot to clear the local selection.
__clearLocalSelection | Private slot to clear the local selection.
__createDeviceDirectory | Private slot to create a directory on the device.
__createLocalDirectory | Private slot to create a local directory.
__deleteDeviceDirectory | Private slot to delete an empty directory on the device.
__deleteDeviceDirectoryTree | Private slot to delete a directory and all its subdirectories recursively.
__deleteDeviceFiles | Private slot to delete device files.
__deleteLocalDirectoryTree | Private slot to delete a local directory tree.
__deleteLocalFiles | Private slot to delete a local file.
__deviceHiddenChanged | Private slot handling a change of the device show hidden menu entry.
__findDirectoryItem | Private method to find a file tree item for the given path.
__fsInfoResultReceived | Private slot to show the file system information of the device.
__handleCurrentDir | Private slot to handle a change of the current directory of the device.
__handleError | Private slot to handle errors.
__handleGetDone | Private slot handling a successful copy of a file from the device.
__handleLongListFiles | Private slot to receive a long directory listing.
__handleRsyncDone | Private method to handle the completion of the rsync operation.
__handleRsyncProgressMessage | Private slot handling progress messages sent by the file manager.
__isFileInList | Private method to check, if a file name is contained in a tree widget.
__listLocalFiles | Private method to populate the local files list.
__localHiddenChanged | Private slot handling a change of the local show hidden menu entry.
__newDeviceFile | Private slot to create a new file on the connected device.
__newDeviceList | Private slot to initiate a new long list of the device directory.
__newLocalFile | Private slot to create a new local file.
__openDeviceFiles | Private slot to open the selected device file in an editor window.
__openLocalFiles | Private slot to open the selected local files in editor windows.
__progressInfoDialogFinished | Private slot handling the closing of the progress info dialog.
__renameDeviceFile | Private slot to rename a file on the device.
__renameLocalFile | Private slot to rename a file on the device.
__repopulateLocalFilesList | Private method to re-populate the local files tree.
__showDeviceContextMenu | Private slot to show the REPL context menu.
__showDeviceFileHash | Private slot to show the sha256 hash for a file on the device.
__showFileHash | Private slot to show the calculated hash digest to the user.
__showFileSystemInfo | Private slot to show some file system information.
__showLocalContextMenu | Private slot to show the REPL context menu.
__touchDeviceFiles | Private slot to touch files on the device.
__updateSaveButtonStates | Private slot to update the enabled state of the save buttons.
on_deviceCwd_textChanged | Private slot handling a change of the current device working directory.
on_deviceFileTreeWidget_itemActivated | Private slot to handle the activation of a device item.
on_deviceFileTreeWidget_itemExpanded | Private slot handling the expansion of a local directory item.
on_deviceFileTreeWidget_itemSelectionChanged | Private slot handling a change of selection in the local pane.
on_deviceHomeButton_clicked | Private slot to move to the device home directory.
on_deviceReloadButton_clicked | Private slot to reload the device list.
on_deviceUpButton_clicked | Private slot to go up one directory level on the device.
on_getAsButton_clicked | Private slot to copy the selected file from the connected device with a different name.
on_getButton_clicked | Private slot to copy the selected file from the connected device.
on_localCwd_textChanged | Private slot handling a change of the current local working directory.
on_localFileTreeWidget_itemActivated | Private slot to handle the activation of a local item.
on_localFileTreeWidget_itemExpanded | Private slot handling the expansion of a local directory item.
on_localFileTreeWidget_itemSelectionChanged | Private slot handling a change of selection in the local pane.
on_localHomeButton_clicked | Private slot to change directory to the configured workspace.
on_localReloadButton_clicked | Private slot to reload the local list.
on_localUpButton_clicked | Private slot to go up one directory level.
on_openButton_clicked | Private slot to open the selected file in a new editor.
on_putAsButton_clicked | Private slot to copy the selected file to the connected device with a different name.
on_putButton_clicked | Private slot to copy the selected file to the connected device.
on_saveAsButton_clicked | Private slot to save the current editor in a new file on the connected device.
on_saveButton_clicked | Private slot to save the text of the current editor to a file on the device.
on_syncButton_clicked | Private slot to synchronize the local directory to the device.
start | Public method to start the widget.
stop | Public method to stop the widget.

### Static Methods

None

#### MicroPythonFileManagerWidget (Constructor)

MicroPythonFileManagerWidget(fileManager, parent=None)

Constructor

fileManager (MicroPythonFileManager)
  reference to the device file manager interface
parent (QWidget)
  reference to the parent widget

#### MicroPythonFileManagerWidget.__changeDeviceDirectory

__changeDeviceDirectory()

Private slot to change the current directory of the device.

Note: This triggers a re-population of the device list for the new current directory.

#### MicroPythonFileManagerWidget.__changeLocalDirectory

__changeLocalDirectory(localDevice=False)

Private slot to change the local directory.

localDevice (bool)
  flag indicating device access via local file system

#### MicroPythonFileManagerWidget.__clearDeviceSelection

__clearDeviceSelection()

Private slot to clear the local selection.

#### MicroPythonFileManagerWidget.__clearLocalSelection

__clearLocalSelection()

Private slot to clear the local selection.

#### MicroPythonFileManagerWidget.__createDeviceDirectory

__createDeviceDirectory()

Private slot to create a directory on the device.

#### MicroPythonFileManagerWidget.__createLocalDirectory

__createLocalDirectory(localDevice=False)

Private slot to create a local directory.

localDevice (bool)
  flag indicating device access via local file system

#### MicroPythonFileManagerWidget.__deleteDeviceDirectory

__deleteDeviceDirectory()

Private slot to delete an empty directory on the device.

#### MicroPythonFileManagerWidget.__deleteDeviceDirectoryTree

__deleteDeviceDirectoryTree()

Private slot to delete a directory and all its subdirectories recursively.

#### MicroPythonFileManagerWidget.__deleteDeviceFiles

__deleteDeviceFiles()

Private slot to delete device files.

#### MicroPythonFileManagerWidget.__deleteLocalDirectoryTree

__deleteLocalDirectoryTree(localDevice=False)

Private slot to delete a local directory tree.

localDevice (bool)
  flag indicating device access via local file system

#### MicroPythonFileManagerWidget.__deleteLocalFiles

__deleteLocalFiles(localDevice=False)

Private slot to delete a local file.

localDevice (bool)
  flag indicating device access via local file system

#### MicroPythonFileManagerWidget.__deviceHiddenChanged

__deviceHiddenChanged(checked)

Private slot handling a change of the device show hidden menu entry.

checked (bool)
  new check state of the action

#### MicroPythonFileManagerWidget.__findDirectoryItem

__findDirectoryItem(dirPath, fileTreeWidget)

Private method to find a file tree item for the given path.

dirPath (str)
  path to be searched for
fileTreeWidget (QTreeWidget)
  reference to the file list to be searched

Return:
  reference to the item for the path

Return Type:
  QTreeWidgetItem

#### MicroPythonFileManagerWidget.__fsInfoResultReceived

__fsInfoResultReceived(fsinfo)

Private slot to show the file system information of the device.

fsinfo (tuple of tuples of (str, int, int, int))
  tuple of tuples containing the file system name, the total size, the used size and the free size

#### MicroPythonFileManagerWidget.__handleCurrentDir

__handleCurrentDir(dirname)

Private slot to handle a change of the current directory of the device.

dirname (str)
  name of the current directory

#### MicroPythonFileManagerWidget.__handleError

__handleError(method, error)

Private slot to handle errors.

method (str)
  name of the method the error occured in
error (str)
  error message

#### MicroPythonFileManagerWidget.__handleGetDone

__handleGetDone(_deviceFile, localFile)

Private slot handling a successful copy of a file from the device.

_deviceFile (str)
  name of the file on the device (unused)
localFile (str)
  name of the local file

#### MicroPythonFileManagerWidget.__handleLongListFiles

__handleLongListFiles(dirname, filesList)

Private slot to receive a long directory listing.

dirname (str)
  name of the directory the list of files belongs to
filesList (tuple of (str, str, str, str))
  tuple containing tuples with name, mode, size and time for each directory entry

#### MicroPythonFileManagerWidget.__handleRsyncDone

__handleRsyncDone(_localDir, _deviceDir)

Private method to handle the completion of the rsync operation.

_localDir (str)
  name of the local directory (unused)
_deviceDir (str)
  name of the device directory (unused)

#### MicroPythonFileManagerWidget.__handleRsyncProgressMessage

__handleRsyncProgressMessage(message)

Private slot handling progress messages sent by the file manager.

message (str)
  message to be shown

#### MicroPythonFileManagerWidget.__isFileInList

__isFileInList(filename, parent)

Private method to check, if a file name is contained in a tree widget.

filename (str)
  name of the file to check
parent (QTreeWidget or QTreeWidgetItem)
  reference to the parent to be checked against

Return:
  flag indicating that the file name is present

Return Type:
  bool

#### MicroPythonFileManagerWidget.__listLocalFiles

__listLocalFiles(dirname="", localDevice=False, parentItem=None)

Private method to populate the local files list.

dirname (str (optional))
  name of the local directory to be listed (defaults to "")
localDevice (bool (optional))
  flag indicating device access via local file system (defaults to False)
parentItem (QTreeWidgetItem (optional))
  reference to the parent item (defaults to None)

#### MicroPythonFileManagerWidget.__localHiddenChanged

__localHiddenChanged(checked)

Private slot handling a change of the local show hidden menu entry.

checked (bool)
  new check state of the action

#### MicroPythonFileManagerWidget.__newDeviceFile

__newDeviceFile()

Private slot to create a new file on the connected device.

#### MicroPythonFileManagerWidget.__newDeviceList

__newDeviceList()

Private slot to initiate a new long list of the device directory.

#### MicroPythonFileManagerWidget.__newLocalFile

__newLocalFile(localDevice=False)

Private slot to create a new local file.

localDevice (bool)
  flag indicating device access via local file system

#### MicroPythonFileManagerWidget.__openDeviceFiles

__openDeviceFiles()

Private slot to open the selected device file in an editor window.

#### MicroPythonFileManagerWidget.__openLocalFiles

__openLocalFiles()

Private slot to open the selected local files in editor windows.

#### MicroPythonFileManagerWidget.__progressInfoDialogFinished

__progressInfoDialogFinished()

Private slot handling the closing of the progress info dialog.

#### MicroPythonFileManagerWidget.__renameDeviceFile

__renameDeviceFile()

Private slot to rename a file on the device.

#### MicroPythonFileManagerWidget.__renameLocalFile

__renameLocalFile(localDevice=False)

Private slot to rename a file on the device.

localDevice (bool (optional))
  flag indicating device access via local file system (defaults to False)

#### MicroPythonFileManagerWidget.__repopulateLocalFilesList

__repopulateLocalFilesList(dirname="", localDevice=False)

Private method to re-populate the local files tree.

dirname (str (optional))
  name of the local directory to be listed (defaults to "")
localDevice (bool (optional))
  flag indicating device access via local file system (defaults to False)

#### MicroPythonFileManagerWidget.__showDeviceContextMenu

__showDeviceContextMenu(pos)

Private slot to show the REPL context menu.

pos (QPoint)
  position to show the menu at

#### MicroPythonFileManagerWidget.__showDeviceFileHash

__showDeviceFileHash()

Private slot to show the sha256 hash for a file on the device.

#### MicroPythonFileManagerWidget.__showFileHash

__showFileHash(deviceFileName, hashDigest)

Private slot to show the calculated hash digest to the user.

deviceFileName (str)
  name of the file on the device
hashDigest (str)
  calculated hash digest

#### MicroPythonFileManagerWidget.__showFileSystemInfo

__showFileSystemInfo()

Private slot to show some file system information.

#### MicroPythonFileManagerWidget.__showLocalContextMenu

__showLocalContextMenu(pos)

Private slot to show the REPL context menu.

pos (QPoint)
  position to show the menu at

#### MicroPythonFileManagerWidget.__touchDeviceFiles

__touchDeviceFiles()

Private slot to touch files on the device.

#### MicroPythonFileManagerWidget.__updateSaveButtonStates

__updateSaveButtonStates()

Private slot to update the enabled state of the save buttons.

#### MicroPythonFileManagerWidget.on_deviceCwd_textChanged

on_deviceCwd_textChanged(cwd)

Private slot handling a change of the current device working directory.

cwd (str)
  current device working directory

#### MicroPythonFileManagerWidget.on_deviceFileTreeWidget_itemActivated

on_deviceFileTreeWidget_itemActivated(item, _column)

Private slot to handle the activation of a device item.

If the item is a directory, the current working directory is changed and the list will be re-populated for this directory.

item (QTreeWidgetItem)
  reference to the activated item
_column (int)
  column of the activation (unused)

#### MicroPythonFileManagerWidget.on_deviceFileTreeWidget_itemExpanded

on_deviceFileTreeWidget_itemExpanded(item)

Private slot handling the expansion of a local directory item.

item (QTreeWidgetItem)
  reference to the directory item

#### MicroPythonFileManagerWidget.on_deviceFileTreeWidget_itemSelectionChanged

on_deviceFileTreeWidget_itemSelectionChanged()

Private slot handling a change of selection in the local pane.

#### MicroPythonFileManagerWidget.on_deviceHomeButton_clicked

on_deviceHomeButton_clicked()

Private slot to move to the device home directory.

#### MicroPythonFileManagerWidget.on_deviceReloadButton_clicked

on_deviceReloadButton_clicked()

Private slot to reload the device list.

#### MicroPythonFileManagerWidget.on_deviceUpButton_clicked

on_deviceUpButton_clicked()

Private slot to go up one directory level on the device.

#### MicroPythonFileManagerWidget.on_getAsButton_clicked

on_getAsButton_clicked()

Private slot to copy the selected file from the connected device with a different name.

#### MicroPythonFileManagerWidget.on_getButton_clicked

on_getButton_clicked(getAs=False)

Private slot to copy the selected file from the connected device.

getAs (bool)
  flag indicating to give it a new name

#### MicroPythonFileManagerWidget.on_localCwd_textChanged

on_localCwd_textChanged(cwd)

Private slot handling a change of the current local working directory.

cwd (str)
  current local working directory

#### MicroPythonFileManagerWidget.on_localFileTreeWidget_itemActivated

on_localFileTreeWidget_itemActivated(item, _column)

Private slot to handle the activation of a local item.

If the item is a directory, the list will be re-populated for this directory.

item (QTreeWidgetItem)
  reference to the activated item
_column (int)
  column of the activation (unused)

#### MicroPythonFileManagerWidget.on_localFileTreeWidget_itemExpanded

on_localFileTreeWidget_itemExpanded(item)

Private slot handling the expansion of a local directory item.

item (QTreeWidgetItem)
  reference to the directory item

#### MicroPythonFileManagerWidget.on_localFileTreeWidget_itemSelectionChanged

on_localFileTreeWidget_itemSelectionChanged()

Private slot handling a change of selection in the local pane.

#### MicroPythonFileManagerWidget.on_localHomeButton_clicked

on_localHomeButton_clicked()

Private slot to change directory to the configured workspace.

#### MicroPythonFileManagerWidget.on_localReloadButton_clicked

on_localReloadButton_clicked()

Private slot to reload the local list.

#### MicroPythonFileManagerWidget.on_localUpButton_clicked

on_localUpButton_clicked()

Private slot to go up one directory level.

#### MicroPythonFileManagerWidget.on_openButton_clicked

on_openButton_clicked()

Private slot to open the selected file in a new editor.

#### MicroPythonFileManagerWidget.on_putAsButton_clicked

on_putAsButton_clicked()

Private slot to copy the selected file to the connected device with a different name.

#### MicroPythonFileManagerWidget.on_putButton_clicked

on_putButton_clicked(putAs=False)

Private slot to copy the selected file to the connected device.

putAs (bool)
  flag indicating to give it a new name

#### MicroPythonFileManagerWidget.on_saveAsButton_clicked

on_saveAsButton_clicked()

Private slot to save the current editor in a new file on the connected device.

#### MicroPythonFileManagerWidget.on_saveButton_clicked

on_saveButton_clicked(saveAs=False)

Private slot to save the text of the current editor to a file on the device.

saveAs (bool)
  flag indicating to save the file with a new name

#### MicroPythonFileManagerWidget.on_syncButton_clicked

on_syncButton_clicked()

Private slot to synchronize the local directory to the device.

#### MicroPythonFileManagerWidget.start

start()

Public method to start the widget.

#### MicroPythonFileManagerWidget.stop

stop()

Public method to stop the widget.

Up